/*
 * @Descripttion: 返回用户列表
 * @version: 1.0
 * @Author: 自由如风
 * @Date: 2021-04-28 09:05:01
 * @LastEditors: 自由如风
 * @LastEditTime: 2021-04-28 09:20:56
 */

const DB = require('../../lib/DB')
const { Success } = require('../../lib/Response')

module.exports = async function (ctx, next) {
    const users = await DB.models.user.findAll({ limit: ctx.request.query.limit, offset: ctx.request.query.offset })
    if (!!users) {
        ctx.body = new Success(users.map(e => e.toJSON()))
        await next()
    } else {
        throw new Error("查询失败")
    }
}